/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package point.of.sale.app;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.swing.JOptionPane;


public class AboutAP extends javax.swing.JFrame {

    /** Creates new form AboutAP */
     public void readFromFile()
    {
    String txt = new String();
    SQLHandler sqlh = new SQLHandler();
    File file = new File(sqlh.executionPath+"/About.txt");
    FileInputStream fis = null;
    BufferedInputStream bis = null;
    DataInputStream dis = null;

    try {
      fis = new FileInputStream(file);

      bis = new BufferedInputStream(fis);
      dis = new DataInputStream(bis);

      while (dis.available() != 0) {

          txt = txt + dis.readLine() + "\n";
          //System.out.println(dis.readLine());
          AboutTextArea.setText(txt);
      }

      // dispose all the resources after using them.
      fis.close();
      bis.close();
      dis.close();

    } catch (FileNotFoundException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null,e.toString());
    } catch (IOException e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(null,e.toString());
    }
    }

    public AboutAP() {
        initComponents();
        this.readFromFile();

        setLocationRelativeTo(null);
       }



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        AboutScrollPane = new javax.swing.JScrollPane();
        AboutTextArea = new javax.swing.JTextArea();
        CloseButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        AboutTextArea.setColumns(20);
        AboutTextArea.setEditable(false);
        AboutTextArea.setLineWrap(true);
        AboutTextArea.setRows(5);
        AboutTextArea.setWrapStyleWord(true);
        AboutScrollPane.setViewportView(AboutTextArea);

        CloseButton.setText("Close");
        CloseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CloseButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(CloseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(AboutScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(AboutScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 242, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(CloseButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void CloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CloseButtonActionPerformed
        // TODO add your handling code here:
        this.dispose();
        this.setVisible(false);
    }//GEN-LAST:event_CloseButtonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void AboutAP_main() {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new AboutAP().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane AboutScrollPane;
    private javax.swing.JTextArea AboutTextArea;
    private javax.swing.JButton CloseButton;
    // End of variables declaration//GEN-END:variables

}